var status = -1;
var selectionLog = [];

function action(c, b, a) {
    cm.onActionBarResult(5, 100);
    if (cm.isQuestActive(17005)) {
        action1(c, b, a)
    } else {
        if (cm.isQuestActive(17006)) {
            action2(c, b, a)
        } else {
            if (cm.isQuestActive(17007)) {
                action3(c, b, a)
            } else {
                cm.dispose()
            }
        }
    }
}

function action1(d, c, b) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }
    status++;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            cm.sendNormalTalk("你好，#h0# 。我先介绍下我自己吧。我是提皮斯，我以后会帮助你们进行航海。", 5, 9390225, false, true)
        } else {
            if (status === a++) {
                cm.sendNormalTalk("啊哈哈，一想要和勇士你一起航海了，我的心情就好激动啊！", 5, 9390225, true, true)
            } else {
                if (status === a++) {
                    cm.sendNormalTalk("我好像在哪见过你…… 额…… 肯定是我搞错了吧。", 5, 9390225, true, true)
                } else {
                    if (status === a++) {
                        cm.forceStartQuest(17005, "");
                        cm.dispose()
                    }
                }
            }
        }
    }
}

function action2(d, c, b) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }
    status++;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            cm.sendNormalTalk("很高兴能再次见到你。", 5, 9390225, false, true)
        } else {
            if (status === a++) {
                cm.sendNormalTalk("好久没这么安静的航海了。哈哈哈，看来幸运女神时常陪伴着你啊", 5, 9390225, true, true)
            } else {
                if (status === a++) {
                    cm.forceStartQuest(17006, "");
                    cm.dispose()
                }
            }
        }
    }
}

function action3(d, c, b) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }
    status++;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            cm.sendNormalTalk("船长！那边远处出现了怪物。", 5, 9390225, false, true)
        } else {
            if (status === a++) {
                cm.sendNormalTalk("如果出现怪物的话，请按舰船技能击退怪物！", 5, 9390225, true, true)
            } else {
                if (status === a++) {
                    cm.spawnMobLimit(9390823, 1, 200, 185, 100);
                    cm.dispose()
                }
            }
        }
    }
}

function start() {
    status = -1;
    action(1, 0, 0)
};